function getarr<T>(count: number, value: T): T[] {
    let array: T[] = []
    for (let index = 0; index < count; index++) {

        array.push(value)

    }
    return array

}
console.log(getarr<string>(10, "你是"));

// 多个泛型参数
let arr = function fn<T, R>(a: T, b: R): [T, R] {
    return [a, b]

}
console.log(arr("哈哈", 999));
/**************************泛型 接口****************************** */
interface getaxios<T> {
    headers: string
    config: object
    status: number
    statusText: string
    data: T
}
// 学生
interface students {
    name: string,
    age: number,

}
// 学生
let result: getaxios<object> = {
    headers: "哈哈",
    config: {},
    status: 200,
    statusText: "成功",
    data: {
        value: "你是"
    }
}
console.log(result);
// 学生管理
let result1: getaxios<students> = {
    headers: "哈哈",
    config: {},
    status: 200,
    statusText: "成功",
    data: {
        name: "张三",
        age: 23
    }
}
console.log(result1);
// 书籍管理
interface book {
    bookname: string
    price: number

}
// 学生书籍管理
interface studentsbook<T> {
    name: string,
    age: number,
    data: T
}

let result3: getaxios<studentsbook<book[]>> = {

    headers: "哈哈",
    config: {},
    status: 200,
    statusText: "成功",
    data: {
        name: "李四",
        age: 88,
        data:
            [{ bookname: "一千零一夜", price: 12.5 },
            { bookname: "一千零一夜", price: 12.5 },
            { bookname: "一千零一夜", price: 12.5 },
            { bookname: "一千零一夜", price: 12.5 },
            { bookname: "一千零一夜", price: 12.5 },

            ]
    }
}
console.log(result3);

/************************** 泛型类   ******************************8 */

class result4<T>{
    name:T[]
    constructor(name:T[]){
        this.name=name

    }
}

let res = new result4<string>(["abc","dec","ref"])
console.log(res);




